package com.csnf.service.impl;

import com.csnf.feign.BookFeignClirnt;
import com.csnf.mapper.BorrowMapper;
import com.csnf.service.BorrowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class BorrowServiceImpl implements BorrowService {

    @Autowired
    BorrowMapper borrowMapper;

    @Autowired
    BookFeignClirnt  bookFeignClirnt;

    @Override
    public void borrowBook(Integer bookId, Integer userId) {
        //1.添加借阅记录
        borrowMapper.addRecord(bookId, userId);

        //2.减库存
        bookFeignClirnt.reduceStock(bookId);

    }
}
